package com.liohi.ExceptionCatch;

import com.liohi.AllEunm.MyErrorCode;
import lombok.Data;


/**
 * @author liohi
 */
@Data
public class MyException extends RuntimeException {

    private Integer code;
    private String message;

    public MyException() {

    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public MyException(String message) {
        super(message);
    }

    public MyException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    //定义枚举类，以错误码加信息的形式返回
    public MyException(MyErrorCode errorCode) {
        this.message = errorCode.getMsg();
        this.code = errorCode.getCode();
    }

}
